These small samples shows how you can write code work with EPT document from a Content Studio Web page.
Read an EPT field
This code works in presentation templates only. The code uses the
if(CS_DataFields != null)
{
//Read the value of a EPT data field named Title
string theString = "";
//first check if the field really exists.
if(CS_DataFields.ExistsField("Title"))
{
theString = CS_DataFields["Title"];
//Write out the value
Response.Write(Server.HtmlEncode(theString));
}
}
If Not CS_DataFields Is Nothing Then
'Read the value of a EPT data field named Title
'first check if the field really exists.
Dim theString As String = ""
If CS_DataFields.ExistsField("Title") Then
theString = CS_DataFields("Title")
'Write out the value
Response.Write(Server.HtmlEncode(theString))
End If
End If
Read an EPT field with an EPT document identifier
This code works in any Content Studio document. The code uses the
int documentID = 4372;
ContentStudio.Document.EPT.EPTXmlTextParser ept;
Response.Write("<dl>");
try
{
//Get the EPT document
ept = CS_GetAnyEPTDocument(documentID);
foreach(string fieldName in ept)
{
Response.Write("<dt>" + fieldName + </dt>);
Response.Write("<dd>");
//Check if the field is empty or null
if(!ept.IsEmptyField(fieldName))
Response.Write(Server.HtmlEncode(ept[fieldName]));
else
Response.Write("The value is empty or unspecified");
Response.Write("</dd>");
}
}
catch(ContentStudio.CSException ex)
{
Response.Write("<dt>" + Server.HtmlEncode(CS_TranslateMessage(ex)) + "</dt>");
}
catch(Exception ex)
{
Response.Write("<dt>" + Server.HtmlEncode(ex.Message) + "</dt>");
}
Response.Write("</dl>");
Dim documentID As Integer = 4372
Dim ept As ContentStudio.Document.EPT.EPTXmlTextParser
Response.Write("<dl>")
Try
'Get the EPT document
ept = CS_GetAnyEPTDocument(documentID)
For Each fieldName As String In ept
Response.Write("<dt>" & fieldName & </dt>)
Response.Write("<dd>")
'Check if the field is empty or null
If(Not ept.IsEmptyField(fieldName))
Response.Write(Server.HtmlEncode(ept(fieldName)))
Else
Response.Write("The value is empty or unspecified")
End If
Response.Write("</dd>")
Next
Catch ex As ContentStudio.CSException
Response.Write("<dt>" & Server.HtmlEncode(CS_TranslateMessage(ex)) & "</dt>")
Catch ex As Exception
Response.Write("<dt>" & Server.HtmlEncode(ex.Message) & "</dt>")
End Try
Response.Write("</dl>")